package com.limao.CacheManager;

import com.Hazelcast.Cache;
import com.Hazelcast.CacheFactory;
import com.limao.DBDataClass.UserAddressDataClass;
import com.limao.DBProvider.UserAddressProvider;
import com.limao.cache.BasicModule;

public class user_addressCacheManager  extends BasicModule{

	
	private UserAddressProvider provider;
    
	private static user_addressCacheManager instance;

	public static user_addressCacheManager getInstance() {
	        return instance;
	}
	     
	 private Cache<String, UserAddressDataClass> user_addressManagerCache;


	public user_addressCacheManager() {
    	super("userAddressCacheManager");
    	user_addressManagerCache = CacheFactory.createCache("cd_userAddressDataClass");
	    initProvider();
	}
	    
    @Override
	public void initialize() {
        super.initialize();
        instance=this;
    }
    
    public void ClearObjectCache(String userid)
    {
    	UserAddressDataClass user =user_addressManagerCache.get(userid);
    	if(user!=null)
    	{
    		user_addressManagerCache.remove(user.id);
    	}
    }  
  
     //新鲜宝   查询 by id    
    public UserAddressDataClass load_User_Address_UserDef(int id) { 
        if ( id<1)     return null;
        UserAddressDataClass obj = provider.load_User_Address_UserDef(id);
        return obj;
    }
  
    //*************************************************************  
    private void initProvider() {
        if (provider == null ) {
            try {
                provider =UserAddressProvider.getInstance();
            }
            catch (Exception e) {
            	e.printStackTrace();
            }
        }
    }
  
}



